/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.myapp.struts.TablasEquivalencias;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 *
 * @author Andreina Wilhelm
 */
public class MateriasEquivalentesForm extends org.apache.struts.action.ActionForm {

    private String ID_materiasEquiv;
    private String ID_MateriaOrigen;
    private String ID_MateriaDestino;

    public String getID_materiasEquiv() {
        return ID_materiasEquiv;
    }

    public void setID_materiasEquiv(String ID_materiasEquiv) {
        this.ID_materiasEquiv = ID_materiasEquiv;
    }
    
    public String getID_MateriaOrigen() {
        return ID_MateriaOrigen;
    }

    public void setID_MateriaOrigen(String ID_MateriaOrigen) {
        this.ID_MateriaOrigen = ID_MateriaOrigen;
    }

    public String getID_MateriaDestino() {
        return ID_MateriaDestino;
    }

    public void setID_MateriaDestino(String ID_MateriaDestino) {
        this.ID_MateriaDestino = ID_MateriaDestino;
    }

    
    /**
     *
     */
    public MateriasEquivalentesForm() {
        super();
        // TODO Auto-generated constructor stub
    }
    

    /**
     * This is the action called from the Struts framework.
     *
     * @param mapping The ActionMapping used to select this instance.
     * @param request The HTTP Request we are processing.
     * @return
     */
    @Override
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();

        // validar el seleccionado no sea Seleccione...
        if (this.ID_MateriaOrigen.equals("Seleccione...") || this.ID_MateriaDestino.equals("Seleccione...")) {
            errors.add("err_op", new ActionMessage("errors.select2", "asignatura de origen y/o destino"));    
        }

        return errors;
    }

    
    @Override
    public void reset(ActionMapping mapping, HttpServletRequest request) {
        // reset properties
        this.ID_MateriaOrigen = "";
        this.ID_MateriaDestino = "";
    }
}
